<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>AngularJs集合数据遍历显示</title>
		<script type="text/javascript" src="../js/angular.min.js"></script>
	</head>
	<body ng-app="myapp" ng-controller="myctrl">
		<table>
			<tr>
				<th>序号</th>
				<th>商品编号</th>
				<th>商品名称</th>
				<th>价格</th>
			</tr>
			<tr ng-repeat="product in products">
				<td>{{$index+1}}</td>
				<td>{{product.id}}</td>
				<td>{{product.name}}</td>
				<td>{{product.price}}</td>
			</tr>
		</table>
	</body>
	<script type="text/javascript">
			// 初始化myapp模型
			var myapp = angular.module("myapp",[]);
			// 定义模块的控制器
			// 依赖注入,$scope作用域对象,操作当前作用域范围
			myapp.controller("myctrl",["$scope",function($scope){
				$scope.products = [
				{
					id : 1001,
					name : '数码相机',
					price : 3000
				},{
					id : 1002,
					name : '笔记本',
					price : 7999
				}
				];
			}])
		</script>
</html>
